from django.shortcuts import render, redirect
from testdemo import models
import time, datetime
from django.core.paginator import Paginator,Page


# Create your views here.

def test1Demo(request):
    ret = models.T_newsTables.objects.all()
    # paginator = Paginator(ret, 10)
    #
    # current_page = request.GET.get('page')
    # current_page = int(current_page)
    # posts = paginator.page(current_page)
    return render(request, 'test.html', {'headline_list': ret,
                                          })
def test2Demo(request):
    return render(request, "test.html")


# def test1(request):
#     ret = models.T_newsTables.objects.all().filter(emotion=1)
#     return render(request, 'test1.html', {'headline_list': ret,
#                                           })
#
#
# def test2(request):
#     ret = models.T_newsTables.objects.all().filter(emotion=0)
#     return render(request, 'test2.html', {'headline_list': ret,
#                                           })
#
#
# def test3(request):
#     ret = models.T_newsTables.objects.all().filter(emotion=2)
#     return render(request, 'test3.html', {'headline_list': ret,
#                                           })
#
#
# def sort1(request):
#     ret = models.T_newsTables.objects.all().order_by('-post_date')
#
#     return render(request, 'sort1.html', {'headline_list': ret,
#                                           })
#
#
# def sort2(request):
#     ret = models.T_newsTables.objects.all().order_by('post_date')
#
#     return render(request, 'sort1.html', {'headline_list': ret,
#                                           })
#
#
# def sort3(request):
#     return render(request, "sort3.html")
#
#
# def time1(request):
#     time1 = time.strftime('%Y-%m-%d', time.localtime(time.time()))
#     ret = models.T_newsTables.objects.all().filter(post_date=time1)
#     return render(request, 'time1.html', {'headline_list': ret,
#                                           })
#
#
# def time2(request):
#     time1 = time.strftime('%Y-%m-%d', time.localtime(time.time() - 86400))
#     ret = models.T_newsTables.objects.all().filter(post_date=time1)
#     return render(request, 'time2.html', {'headline_list': ret,
#                                           })
#
#
# def time3(request):
#     time1 = time.strftime('%Y-%m-%d', time.localtime(time.time() - 2592000))
#     ret = models.T_newsTables.objects.all().filter(post_date__gt=time1)
#     return render(request, 'time3.html', {'headline_list': ret,
#                                           })
#
#
# def time4(request):
#     time1 = time.strftime('%Y-%m-%d', time.localtime(time.time() - 604800))
#     ret = models.T_newsTables.objects.all().filter(post_date__gt=time1)
#     return render(request, 'time4.html', {'headline_list': ret,
#                                           })
